import numpy as np
from scipy.spatial.distance import euclidean
from fastdtw import fastdtw


def SpDtw2(X, Y):
    n = len(X) - 1
    m = len(Y) - 1
    x = np.zeros(n)
    y = np.zeros(m)

    for i in range(n):
        x[i] = X[i + 1] - X[i]

    for j in range(m):
        y[j] = Y[j + 1] - Y[j]

    distance, path = fastdtw(x, y, dist=euclidean)
    return distance
